\begin{frame}[fragile]{Life Demo}
A board game for multiple players. Players are included into the following table

{\small
\begin{verbatim}
create table player (  id int primary key );
\end{verbatim}
}
The board can contain pieces from different players, but only one piece at each position. The board state is represented by the following table:

{\small
\begin{verbatim}
create table board (
  int x,
  int y,
  int id,
  primary key x,y,
  foreign key(id) references player(id)) ;
\end{verbatim}}
\end{frame}
\begin{frame}[fragile]{Life Demo}

{\small
\begin{verbatim}
create view nowPlaying(id) as
  select p.id
  from player p
  where exists (select b.id from board b where b.id=p.id);

create view checked(id) as
 select p.id
 from player p
 where exists (select n.id from nowPlaying n where n.id = p.id) and
   not exists (select b1.id from board b1
     where b1.id = p.id and
       not exists
         (select b2.id from board b2
         (b2.x = b1.x or b2.y = b1.y) and (b1.id <> b2.id)));
\end{verbatim}}

\end{frame}